﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Configuration;

namespace ServicioActualizacion
{
    public partial class ServiceActualizacion : ServiceBase
    {

        private Thread _thread;

        public ServiceActualizacion()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            base.OnStart(args);


            int cantMiliSegundos = int.Parse(ConfigurationManager.AppSettings["sleepMiliSegundos"]);
            Actualizacion actualizacion = new Actualizacion(cantMiliSegundos);
            _thread = new Thread(new ThreadStart(actualizacion.CorrerActualizacion));
            _thread.Start();

        }

        protected override void OnStop()
        {
            if (_thread != null)
            {
                _thread.Abort();
            }
        }
    }
}
